package com.example.evensystem.model.entity

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Entity
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.PrimaryKey
import androidx.room.Query
import androidx.room.Update
import java.time.Year

@Entity(tableName = "worker")
data class Worker(
    //工号
    @PrimaryKey
    val id: String,
    //姓名
    var name: String = "",
    //入职年份
    var workYear: String,//YYYY
    //性别
    var sex: Int = 1,//1男，0女
    //职位
    var job: String = "",

    )

@Dao
interface WorkerDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(worker: Worker)

    @Query("select * from worker where id=:id")
    fun findWorker(id: String) : List<Worker>

    @Query("select * from worker")
    fun findAllWorker():List<Worker>

    @Update
    fun update(worker: Worker)

    @Delete
    fun delete(worker: Worker)
}
